JgfMultiGraph   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 5

4 Functions

Rating   Name   Duplication   Size   Complexity  
A metadata 0 4 1
A graphs 0 3 1
A addGraph 0 3 1
A constructor 0 7 1
1
const { Guard } = require('./guard');
2
3
/**
4
 * Container for multiple Jgf graph objects in one object.
5
 */
6
class JgfMultiGraph {
7
8
    /**
9
     * Constructor
10
     * @param {string} type Multi graph classification.
11
     * @param {string} label A text display for the multi graph.
12
     * @param {object|null} metadata Custom multi graph metadata.
13
     */
14
    constructor(type, label, metadata = null) {
15
        this.type = type;
16
        this.label = label;
17
        this._metadata = metadata;
18
19
        this._graphs = [];
20
    }
21
22
    /**
23
     * Adds a single graph.
24
     * @param {JgfGraph} graph Graph to be added.
25
     */
26
    addGraph(graph) {
27
        this._graphs.push(graph);
28
    }
29
30
    /**
31
     * Returns all graphs.
32
     */
33
    get graphs() {
34
        return this._graphs;
35
    }
36
37
    /**
38
     * Sets the multi graph meta data.
39
     */
40
    set metadata(metadata) {
41
        Guard.assertValidMetadata(metadata);
42
        this._metadata = metadata;
43
    }
44
45
    /**
46
     * Returns the multi graph meta data.
47
     */
48
    get metadata() {
49
        return this._metadata;
50
    }
51
}
52
53
module.exports = {
54
    JgfMultiGraph,
55
};